
import { createPortal } from 'react-dom';
import styles from './modaleWindows.module.scss';
import { ReactNode } from 'react';

interface ModalProps {
	children: ReactNode;
	onClose: ()  => void
  }


export const Modal = ({children, onClose}: ModalProps) => {
	const modalElement = document.getElementById('modal');
	if (!modalElement) {
		return null; // Обработка случая, если элемент с id 'modal' не найден
	}
	return createPortal(
		(
			<div className={styles.container} onClick={onClose}>
				<div onClick={(e) => e.stopPropagation()} className={styles.ballCart}>{children}
					<button onClick={onClose} className={styles.close}>X</button>
				</div>
			</div>
		),
		modalElement
	); 
};
